let  nodemailer = require("nodemailer");
let  JsonMessage = require("../models/JsonMessage");
let  UserTasksDao = require("../dao/userTasksDao");
let transporter = nodemailer.createTransport({
    service:'qq',
    host:'smtp.qq.com',
    secureConnection: true,
    auth: {
        user:'790467788@qq.com',
        //pass:'xlphgavuwzbubbjj'
        pass:'mxflpusrdkerbbdb'
    }


});
 let sendMail = function (sendToWho,sendWhat){
     let mailOptions = {
         from:"790467788@qq.com",
         to:`${sendToWho}`,
         subject:"Task Notification",
         text:"text plain",
         html:`<div>${sendWhat}</div>`
     };
     transporter.sendMail(mailOptions, function(error, info){
         if(error){
             console.log(error);
         }

         console.log(info);
     })
 }
module.exports = {
    taskEmailNotification :function (req,res) {
    setTimeout(
        sendMail,req.body.sendTime*1000,req.body.sendToWho,req.body.sendWhat
    )

     res.json(new JsonMessage("1119",null,"Emial Notification Setting Sucess"))


    },
    sendMailFunction:sendMail
}